<?php
class Admin_Form_NewsItem_ValidateImage{
	
	public static function validate($arrParam = null, $options = null){
		$upload = new Zend_File_Transfer_Adapter_Http();
		$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'], 'fileConfig'=>'news-category.ini'));
		$imageConfig = $config->getConfig('item');
		$fileInfo = $upload->getFileInfo('picture');
		$fileName = $fileInfo['picture']['name'];
		if(!empty($fileName)){
			$upload->addValidator('Extension',true,$imageConfig['extension'],'picture')
			 	   ->addValidator('Size',true,$imageConfig['size'],'picture')
				   ->addValidator('ImageSize',true,$imageConfig['imageSize'],'picture');
			if(!$upload->isValid('picture')){
				$message = $upload->getMessages();
				$error = current($message);							
			}
		}
		return $error;	
	}
	
}